package com.h2cloud;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @author: wulongkai
 * @create: 2022-08-19 19:51
 **/
public class 打印 {
    public static void main(String[] args) {
//        List<String> list = new ArrayList<>();
//        list.add("1");
//        list.add("2");
//        list.add("3");
//        list.add("4");
//        for (String i : list) {
//            list = list.stream().filter(e -> !e.equals("2")).collect(Collectors.toList());
//        }
//        list.forEach(e -> {
//            System.out.println(e);
//        });

//        person p = new person();
//        p.setIsBoy(true);
//        System.out.println(p.isBoy);
//        System.out.println(p.isGirl);
//        System.out.println(p.age);
//        System.out.println(p.age2);
//
//        List<Integer> list = null;
//        System.out.println("list.size() = " + list.size());
//        System.out.println(list);
//        if (CollectionUtils.isEmpty(list)){
//            System.out.println("null");
//        }

//        Integer operateType = 8;
//        Integer value1 = new Integer(8);
//        if (operateType == null || (operateType != value1 && operateType != 12)) {
//            System.out.println("yes");
//        } else {
//            System.out.println("no");
//        }
//        System.out.println();
//        Integer type = 3;
//        Integer type = 12;
//        if (operateType == 12 && type != 3 && type != 11) {
//            System.out.println("不支持跳过");
//        }else {
//            System.out.println("yes");
//        }
//        System.out.println(false || true && false);
//        System.out.println(false && false);

//        person p1 = new person();
//        p1.setAge2(2);
//        person p2 = new person();
//        p2.setAge2(2);
//        System.out.println(p1.age2 == p1.age2);

//        final Instant start = Instant.now();
//        System.out.println("start = " + start);
//        try {
//            Thread.sleep(3000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        final Instant end = Instant.now();
//        System.out.println(Duration.between(start, end).toMillis());
//
//        Instant instant = Instant.now();
//        System.out.println("当前时间戳是:"+instant);
//
//        Date date = Date.from(instant);
//        System.out.println("当前时间戳是:"+date);
//
//        instant = date.toInstant();
//        System.out.println("当前时间戳是:"+instant);


//        String [] ss = new String[]{
//                "zw", "zz"
//        };
//        System.out.println();
//        System.out.println("方法                                值");
//        System.out.println("getName            " + ss.getClass().getName());
//        System.out.println("getCanonicalName   " + ss.getClass().getCanonicalName());
//        System.out.println("getSimpleName      " + ss.getClass().getSimpleName());
//
//        System.out.println();

//        String name = "longkai";
//        System.out.println("StringUtils.isBlank(name) = " + StringUtils.isBlank(name));
//        System.out.println("name = " + name);
//        test(name);
//        System.out.println("name = " + name);

        Date date = new Date();
        System.out.println(getEffectiveDateFromDate(date));

    }

    public static Long getEffectiveDateFromDate(Date date) {
        return getEffectiveDateFromLocalDateTime(getLocalDateTimeFromDate(date));
    }
    public static Long getEffectiveDateFromLocalDateTime(LocalDateTime localDateTime) {
        return getEffectiveDateFromLocalDate(LocalDate.from(localDateTime));
    }

    public static Long getEffectiveDateFromLocalDate(LocalDate localDate) {
        String month = String.valueOf(localDate.getMonthValue());
        month = month.length() > 1 ? month : "0" + month;
        String day = String.valueOf(localDate.getDayOfMonth());
        day = day.length() > 1 ? day : "0" + day;
        return Long.valueOf(localDate.getYear() + month + day);
    }

    public static LocalDateTime getLocalDateTimeFromDate(Date date) {
        if (null == date) {
            return null;
        }
        return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
    }


    public static void test(String str) {
        str = str + "1";
        System.out.println("test" + str);
    }
}

//@Data
//class person {
//    Boolean isBoy;
//    boolean isGirl;
//    boolean isPass = true;
//    int age;
//    Integer age2;
//
//}
